﻿using UnityEngine;
using System.Collections;

public class HpIconDrop : UIDragDropItem
{

    protected override void OnDragDropRelease(GameObject surface)
    {
        Debug.Log("surface tag ===" + surface.tag);
        switch (surface.tag)
        {
            case "hp1":
                var parent1 = surface.transform.parent.transform.parent;
                parent1.GetComponent<UI.UIFieldSetHpPage>().setHpOne(this.gameObject.transform.name);
                break;
            case "hp2":
                var parent2 = surface.transform.parent.transform.parent;
                parent2.GetComponent<UI.UIFieldSetHpPage>().setHpTwo(this.gameObject.transform.name);
                break;
        }

        //    if (!cloneOnDrag)
        //    {
        //        // Re-enable the collider
        //        if (mButton != null) mButton.isEnabled = true;
        //        else if (mCollider != null) mCollider.enabled = true;
        //        else if (mCollider2D != null) mCollider2D.enabled = true;

        //        // Is there a droppable container?
        //        UIDragDropContainer container = surface ? NGUITools.FindInParents<UIDragDropContainer>(surface) : null;

        //        if (container != null)
        //        {
        //            // Container found -- parent this object to the container
        //            mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform;

        //            Vector3 pos = mTrans.localPosition;
        //            pos.z = 0f;
        //            mTrans.localPosition = pos;
        //        }
        //        else
        //        {
        //            // No valid container under the mouse -- revert the item's parent
        //            mTrans.parent = mParent;
        //        }

        //        // Update the grid and table references
        //        mParent = mTrans.parent;
        //        mGrid = NGUITools.FindInParents<UIGrid>(mParent);
        //        mTable = NGUITools.FindInParents<UITable>(mParent);

        //        // Re-enable the drag scroll view script
        //        if (mDragScrollView != null)
        //            StartCoroutine(EnableDragScrollView());

        //        // Notify the widgets that the parent has changed
        //        NGUITools.MarkParentAsChanged(gameObject);

        //        if (mTable != null) mTable.repositionNow = true;
        //        if (mGrid != null) mGrid.repositionNow = true;

        //        // We're now done
        //        OnDragDropEnd();
        //    }
        //    else NGUITools.Destroy(gameObject);

        base.OnDragDropRelease(surface);
    }

}
